package com.Redis.Serviceimpl;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;

import com.Redis.Sublisher.Subscriber;
import com.Redis.Utils.RedisPool;

@Service
public class ConsumerServicesImpl {
	private Logger logger = Logger.getLogger(this.getClass().getName());
	
	@Autowired
	private ThreadPoolTaskExecutor threadPoolTaskExecutor;

	// 启动消费者去消费redis 消息队列中的消息
	@Async
	public void consumption() throws InterruptedException {
		System.err.println("-------------------开始订阅！！！！！--------------------");		
		Subscriber subscriber = new Subscriber(threadPoolTaskExecutor);
		RedisPool.getJedis().subscribe(subscriber, "reportChannel");
	}


	
}
